using Infrastructure.Attribute;
using Infrastructure.Extensions;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Repository;
using JTZY.Service.Order.IOrderService;

namespace JTZY.Service.Order
{
    /// <summary>
    /// 商品图片关联表Service业务层处理
    /// </summary>
    [AppService(ServiceType = typeof(ICorecmsbillaftersalesimagesService), ServiceLifetime = LifeTime.Transient)]
    public class CorecmsbillaftersalesimagesService : BaseService<Corecmsbillaftersalesimages>, ICorecmsbillaftersalesimagesService
    {
        /// <summary>
        /// 查询商品图片关联表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public PagedInfo<CorecmsbillaftersalesimagesDto> GetList(CorecmsbillaftersalesimagesQueryDto parm)
        {
            var predicate = QueryExp(parm);

            var response = Queryable()
                .Where(predicate.ToExpression())
                .ToPage<Corecmsbillaftersalesimages, CorecmsbillaftersalesimagesDto>(parm);

            return response;
        }


        /// <summary>
        /// 获取详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Corecmsbillaftersalesimages GetInfo(string Id)
        {
            var response = Queryable()
                .Where(x => x.AftersalesId == Id)
                .First();

            return response;
        }

        /// <summary>
        /// 添加商品图片关联表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Corecmsbillaftersalesimages AddCorecmsbillaftersalesimages(Corecmsbillaftersalesimages model)
        {
            return Insertable(model).ExecuteReturnEntity();
        }

        /// <summary>
        /// 修改商品图片关联表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateCorecmsbillaftersalesimages(Corecmsbillaftersalesimages model)
        {
            return Update(model, true);
        }

        /// <summary>
        /// 查询导出表达式
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        private static Expressionable<Corecmsbillaftersalesimages> QueryExp(CorecmsbillaftersalesimagesQueryDto parm)
        {
            var predicate = Expressionable.Create<Corecmsbillaftersalesimages>();

            return predicate;
        }
    }
}